$(function(){
    //首页导航鼠标移入移出事件
    //
    var hoverIndex = {},client = {};
    $('#nav li:not(.ro7,.ro8,.ro9) .future').hover(function(e) {
        client = {X:e.clientX,Y:e.clientY};
        var that = $(this),i = that.parents().index();
        if(hoverIndex[i+100]!==undefined){
            clearInterval(hoverIndex[i+100]);
        }
        if(hoverIndex[i] == undefined || hoverIndex[i] == 0){
            that.prev().addClass('hover').find('a').animate({'opacity':0.7}, 300,function(){
                that.prev().removeClass('hover');
                hoverIndex[i] = 1;
            });
        }
    }, function(e) {
        if(client.X == e.clientX || client.Y == e.clientY){
            return false;
        }
        var that = $(this),i = that.parents().index();
        hoverIndex[i+100] = setInterval(function(){
            if(hoverIndex[i] == 1){
                that.prev().find('a').animate({'opacity':0}, 200);
                hoverIndex[i] = 0;
                setInterval(hoverIndex[i+100]);
            }
        }, 50);
    });

    $('#nav li .future').click(function(event) {
        var _href = $(this).prev().find('a').attr('href');
        if(typeof(_href) != 'undefined'){
            window.location.href = _href;
        }
    });


    /**
     * 随即旋转首页导航的角度
     * @param min 数字,最小角度
     * @param max 数字,最大角度
     */
    function rand_nav(min,max){
        var nav_total = $('#nav li').length;
        for(i=0;i<nav_total;i++){
            var rand = parseInt(Math.random()*(max-min+1)+min);
            $('#nav li').eq(i).css({'transform':'rotate('+rand+'deg)'});
        }
    }
    //由于角度不为90°的li无法进行翻转,所以注释掉了旋转
//    rand_nav(-5,5);
})